<?php
$wh = "width:{$this->ad->getWidth()}px;height:{$this->ad->getHeight()}px;";
$styles = $this->ad->getStyle();
$script = $this->ad->getScript();

echo '<div class="advertisement ad-' . $this->ad->getName() . '" id="ad-' . $this->ad->getHash() . '">';
if(!empty($styles)) {
	foreach($styles AS $style) {
		if($this->ad->getIsLayout()) {
			echo '<link href="' . $style . '" rel="stylesheet" type="text/css" />';
		} else {
			$this->headLink()->prependStylesheet($style);
		}
	}
}
if(1 && $styleBody = $this->ad->getStyleBody()) {
	if($this->ad->getIsLayout()) {
		echo '<style type="text/css">' . $styleBody . '</style>';
	} else {
		$this->headStyle()->captureStart();
		echo $styleBody;
		$this->headStyle()->captureEnd();
	}
}

if(1 && $scriptBody = $this->ad->getScriptBody()) {
	echo '<script type="text/javascript">' .  $scriptBody . '</script>';
}
if(!empty($script)) {
	foreach($script AS $src) {
		if($this->ad->getIsLayout() || ($this->ad->getWidth() > 0 && $this->ad->getHeight() > 0)) {
			echo '<script type="text/javascript" src="' . $src . '"></script>';
		} else {
			$this->headScript()->appendFile($src);
		}
	}
} elseif(1 && $resource = $this->ad->getResource()) {
	$pi = pathinfo($resource);
	if(strtolower($pi['extension']) == 'swf') {
		echo 'Flash';
	} else {
		echo '<a href="' . $this->ad->getUrl() . '" target="_blank">';
		echo '<img src="' . $resource . '" style="' . $wh .'" />';
		echo '</a>';
	}
}
echo '</div>' . "\r\n";

